#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn = 30, INF = 0x3f3f3f3f;
LL f[30][2];
int a[maxn], b[maxn];
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++) cin >> a[i];
        for(int i = 1; i <= n; i++) cin >> b[i];
        for(int i = 2; i <= n; i++){
            f[i][0] = min(f[i - 1][0] + abs(a[i] - a[i - 1]) + abs(b[i] - b[i - 1]), 
                          f[i - 1][1] + abs(a[i] - b[i - 1]) + abs(b[i] - a[i - 1]));
            f[i][1] = min(f[i - 1][0] + abs(b[i] - a[i - 1]) + abs(a[i] - b[i - 1]), 
                          f[i - 1][1] + abs(b[i] - b[i - 1]) + abs(a[i] - a[i - 1]));
        }
        //cout << min(f[n][0], f[n][1]) << '\n';
        cout<<"test: "<<f[n][0]<<" "<<f[n][1]<<'\n';
    }
}